package com.yymmarket.util.thread;

import java.util.Date;


public class EverydayThread extends Thread {
	
	private boolean started = true;
	
	public boolean isStarted() {
		return started;
	}

	public void setStarted(boolean started) {
		this.started = started;
	}

	@Override
	public void run() {
		while(started) {
			boolean flag = false;
			Date date = new Date();
			if(date.getHours()==1) {
				ThreadMethod.everydayMethod();
				flag = true;
			} else {
				flag = false;
			}
			
			if(flag) {
				System.out.println("sleep 20 hours");
				try {
					Thread.sleep(60*1000*60*20);
				} catch (Exception e) {
					e.printStackTrace();
				} finally {

				}
			} else {
				System.out.println("sleep 1 hours");
				try {
					Thread.sleep(60*1000*60);
				} catch (Exception e) {
					e.printStackTrace();
				} finally {

				}
			}
		}
	}

}
